home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEM / I-M / LineShare DEMO.sea / LineShare Scripts / GVC Fax&ARA < prev    next >
Text File  |  1992-12-02  |  6KB  |  269 lines

  1. !
  2. ! LineShare™ Script for 2400/9600 data-fax modems (EXAR-based)
  3. !
  4. ! If you want to modify this script for your modem, pay attention to
  5. ! the line marked "#### Settings ####" - it should be modified first
  6. ! This script is written to use with ARA on the "Data" subPort, so
  7. ! the modem is set to the "\N1" mode
  8. !
  9.  
  10. ! ------------------------------------------
  11. ! Resetting the modem:
  12. ! ------------------------------------------
  13. @Hangup
  14.   SetTries 2
  15.   Flush
  16.   HsReset 0,0,17,19,0,0
  17. !
  18. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  19. ! to enter the command mode
  20. !
  21. @Label 1
  22.   matchclr
  23.   matchstr 1 2 "OK\r\n"
  24.   write "ATH0&F\r"
  25.   matchread 20
  26.   Write "+++"
  27.   DtrClear
  28.   pause 10
  29.   DtrSet
  30. !
  31.   DecTries
  32.   IfTries 0 1
  33. !
  34. ! OSErr -6019 "Modem error - the modem is not responding"
  35. !
  36.   exit -6019
  37. @Label 2
  38.   write "AT+FCLASS=0\r"
  39.   Jsr 100
  40.   write "AT+FAA=0\r"
  41.   Jsr 100
  42.   exit 0
  43. ! ------------------------------------------
  44. !    Receiving incoming calls
  45. ! ------------------------------------------
  46. @ANSWER
  47. @Label 10
  48. !
  49. ! Set the modem preferred speed first
  50. !
  51.   SERRESET 2400,0,8,1
  52.   Jsr 80
  53. !
  54. ! Set the common options
  55.   Jsr 70
  56. !
  57. ! Set the communication options:
  58. ! • X4:  Extended response set
  59. ! • \N1: Direct connection (no compression, correction, speed buffering - for ARA)
  60. ! • \Q1: Xon/Xoff flow control (for Fax)
  61. ! • &S1: DSR according to CCITT (if the cable connects CTS with DSR, not DCD)
  62. !
  63. @Label 11
  64. ! #### Settings - change this according to the type of modem you have ####
  65.   Write "ATX4\\N1\\Q1&S1\r"
  66.   Jsr 100
  67. !
  68. ! Set the "work" speed
  69. !
  70. @Label 12
  71.   SERRESET 19200,0,8,1
  72.   Jsr 80
  73. !
  74. ! Set Fax parameters: LID, DCC,BOR
  75. !
  76.   Write "AT+FCLASS=2\r"
  77.   Jsr 100
  78.   Write "AT+FLID=\"Stalker_GmbH\"\r"
  79.   Jsr 100
  80.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  81.   Jsr 100
  82.   Write "AT+FBOR=1\r"
  83.   Jsr 100
  84. !
  85. ! Allow modem to receive fax messages
  86. !
  87.   Write "AT+FCR=1\r"
  88.   Jsr 100
  89. !
  90. ! Tell the modem to determine the type of the incoming call
  91. ! Fetch the tube after N rings, where N has been set in the control panel (^4)
  92. !
  93.   Write "ATS0=^4+FAA=1\r"
  94.   Jsr 100
  95. !
  96. ! Everything is ready - let's sit and wait for a call
  97. ! We'll wait for 2 minutes, then reinitiate the modem
  98. !
  99. @Label 20
  100.   MatchClr
  101.   matchstr 1 20 "RING\r\n"
  102.   matchstr 2 21 "\r\nCONNECT"
  103.   matchstr 3 24 "\r\n+FCON"
  104.   matchstr 4 10 "\r\nNO "
  105.   matchstr 5 10 "\r\nBUSY"
  106.   Matchread 1200
  107.   jump 10
  108. !
  109. ! Data connection has been established (we read "CONNECT")
  110. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  111. ! if it was an incoming call, put the "RING" before the "CONNECT"
  112. !
  113. @Label 21
  114.   LogMsg "Data call…"
  115.   QueueInput "\r\nCONNECT"
  116.   ifOriginate 22
  117.   QueueInput "\r\nRING\r\n"
  118. @Label 22
  119.   Attach "Data" (DTR,Escape,TimeLimit=0)
  120. !
  121. ! Fax connection has been established (we read "+FCON")
  122. ! Put the +FCON back to the buffer,
  123. ! if it was an incoming call, put the "RING" before the "+FCON"
  124. ! Attach the "Fax" subPort
  125. !
  126. @Label 24
  127.   QueueInput "\r\n+FCON"
  128.   ifOriginate 25
  129.   QueueInput "\r\nRING\r\n"
  130. @Label 25
  131.   Attach "Fax" (DTR,RESET,ESCAPE,IDLELimit=30)
  132. ! ------------------------------------------
  133. ! Originating a call through the "Data" subport
  134. ! ------------------------------------------
  135. @ORIGINATE "Data"
  136. !
  137. ! Set the Data speed
  138. !
  139.   SERRESET 2400,0,8,1
  140.   Jsr 80
  141. !
  142. ! Set the common options
  143. !
  144.   Jsr 70
  145. !
  146. ! Set the Data mode:
  147. ! • X4:  Extended response set
  148. ! • \N1: Direct connection (no compression, correction, speed buffering - for ARA)
  149. ! • &S1: DSR according to CCITT (if the cable connects CTS with DSR, not DCD)
  150. ! • S7:  time-out (90 sec) for long-distance call (if you use them)
  151. !
  152. ! #### Settings - change this according to the type of modem you have ####
  153.   Write "ATX4\\N1&S1S7=90\r"
  154.   Jsr 100
  155. !
  156. ! Now emit all commands that the application has sent to that port
  157. ! (if we use ARA/LineShare script, no commands were sent)
  158. !
  159.   Jsr 60
  160. !
  161. ! Prepare to receive all error result codes
  162. !
  163.   Jsr 90
  164.   matchstr 1 21 "\r\nCONNECT"
  165. !
  166. ! Dial the number
  167. !
  168.   HsReset *
  169.   Write "ATD^1\r"
  170.   MatchRead 900
  171.   Write "\r"
  172.   Exit -6019
  173. ! ------------------------------------------
  174. ! Originating a call through the "Fax" subPort
  175. ! ------------------------------------------
  176. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nNO DIALTONE\r\n")
  177. !
  178. ! Set the "Fax" speed
  179. !
  180.   SERRESET 19200,0,8,1
  181.   Jsr 80
  182. !
  183. ! Set the common options
  184. !
  185.   Jsr 70
  186. !
  187. ! Set the Fax mode
  188. ! &S0: DSR always on (see above)
  189. !
  190.   Write "AT&S0+FCLASS=2\r"
  191.   Jsr 100
  192. !
  193. ! Now emit all commands that the application has sent to that port,
  194. ! Prepare to receive all error result codes
  195. !
  196. @LABEL 50
  197.   Jsr 60
  198.   Jsr 90
  199.   MatchStr 1 24 "\r\n+FCON"
  200.   HsReset *
  201.   Write "ATD^1\r"
  202.   MatchRead 700
  203.   Write "\r"
  204.   Exit -6019
  205. !
  206. ! This section emits all modem commands sent from the client application
  207. ! For each set of commands the "OK" answer is awaited
  208. !
  209. @Label 60
  210.   EmitStart
  211. @Label 61
  212.   EmitCommand 62
  213.   Jsr 100
  214.   Jump 61
  215. @Label 62
  216.   return
  217. !
  218. ! This section initiates the modem before ANSWER and ORIGINATEs:
  219. ! factory settings + speaker control +
  220. ! reset on Dtr drop + DCD valid
  221. ! Verbal responses mode, no echo 
  222. !
  223. @Label 70
  224.   Write "ATM^2L^3&D3&C1V1E0\r"
  225.   Jsr 100
  226.   return 
  227. !
  228. ! This section syncronize the modem after the serial port speed switching
  229. !
  230. @Label 80
  231.   ChrDelay 1
  232.   Write "AT\r"
  233.   ChrDelay 0
  234.   Jsr 100
  235.   return
  236. !
  237. ! Prepare to receive error result codes
  238. !
  239. @Label 90
  240.   MatchClr
  241.   MatchStr 2 91 "NO DIALTONE\r\n"
  242.   MatchStr 3 92 "BUSY\r\n"
  243.   MatchStr 4 93 "NO CARRIER\r\n"
  244.   MatchStr 5 94 "NO ANSWER\r\n"
  245.   return
  246. @Label 91
  247.   exit -6020
  248. @Label 92
  249.   exit -6022
  250. @Label 93
  251.   exit -6021
  252. @Label 94
  253.   exit -6023
  254. !
  255. ! Processing the AT command:
  256. ! OK -> proceed
  257. ! ERROR or TimeOut ->exit -6019
  258. ! It can be called AFTER the "Write" command, since LineShare buffers input
  259. !
  260. @Label 100
  261.   MatchClr
  262.   MatchStr 1 102 "\r\nOK\r\n"
  263.   MatchStr 2 101 "\r\nERROR\r\n"
  264.   MatchRead 20
  265. @Label 101
  266.   Exit -6019
  267. @Label 102
  268.   return
  269.